#!/usr/bin/env bash
set -e

# 此脚本用于jenkins执行自动化编译测试打包

export ANDROID_HOME="/opt/android-sdk-linux"
export PATH="$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools:$PATH"
export _JAVA_OPTIONS="-Xmx64M"

npm install
./node_modules/.bin/bower install
./node_modules/.bin/gulp default
./node_modules/.bin/gulp dist
ionic upload
ionic platform add android
ionic build android

now=`date '+%Y-%m-%d_%H:%M:%S'`
cp ./platforms/android/build/outputs/apk/android-debug.apk ~/storage/apk/jl-customer-${now}.apk
curl -d title="Jenkins成功打包" -d text="jl-customer-${now}.apk" https://talk.ai/v1/services/webhook/3fbc1e52ad97f3dc7386d27225231f854cbef1de
